package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.MedicamentBean;
import com.project.service.MedicamentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 药剂
 */
@Controller
@RequestMapping("medicament")
public class MedicamentController {


    @Resource
    private MedicamentService medicamentService;


    /**
     * 分页显示
     * @param pageNO
     * @param pageSize
     * @return
     */
    @RequestMapping("findAllMedicament")
    @ResponseBody
    public IPage<MedicamentBean> findAllMedicament(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                                 @RequestParam(value = "pageSize", defaultValue = "3") int pageSize){
        return medicamentService.findAllMedicament(pageNO,pageSize);
    }


    /**
     * 添加药剂
     * @param medicamentBean
     * @return
     */
    @RequestMapping("addMedicament")
    @ResponseBody
    public String addMedicament(MedicamentBean medicamentBean) {
        medicamentService.addMedicament(medicamentBean);
        return "添加成功";
    }

    /**
     * 药剂名药剂类型药剂类别模糊查询
     * @param pageNO
     * @param pageSize
     * @param medicamentName
     * @param medicamentType
     * @param medicamentCategory
     * @return
     */
    @RequestMapping("findName")
    @ResponseBody
    public IPage<MedicamentBean> findName(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                        @RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
                                        String medicamentName, String medicamentType, String medicamentCategory){
        return medicamentService.findName(pageNO,pageSize,medicamentName,medicamentType,medicamentCategory);
    }
}
